import { useEffect } from "react"
import SyntaxHighlighter from '@/components/SyntaxHighlighter'

const code1 = `
  const setFn = () => {
    const result = []

    for (let i = 2; i < 10000; i++) {
      const item = i.toString()
      const splitArr = item.split('')
      if (splitArr.reverse().join('') === item) {
        result.push(i)
      }
    }
    
    console.log('result', result)
  }
`

function FindSymmetry() {

  const setFn = () => {
    const result = []

    for (let i = 2; i < 10000; i++) {
      const item = i.toString()
      const splitArr = item.split('')
      if (splitArr.reverse().join('') === item) {
        result.push(i)
      }
    }
    
    console.log('result', result)
  }

  useEffect(() => {
    setFn()
  }, [])

  return (
    <div>
      <p>找出1-10000中的对称数字。例如 121、2442</p>
      <p>代码实现逻辑：</p>
      <SyntaxHighlighter children={code1} />
    </div>
  )
}

export default FindSymmetry